package com.tiheima.controller;

import com.tiheima.manager.MinIOManager;
import com.tiheima.model.result.Result;
import com.tiheima.service.EmpService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;

@RestController
@RequestMapping("/upload")
public class FileController {

    @Resource
    private MinIOManager minIOManager;

    @PostMapping
    public Result<?> upload(@RequestParam MultipartFile file) throws Exception {
        return minIOManager.upload(file);
    }

    /**
     * 仅测试用
     * @param urlList 文件名称，如："12/20250517194803-wallhaven-9dmy6x.jpg"
     * @return
     * @throws Exception
     */
    @DeleteMapping
    public Result<?> delect(ArrayList<String> urlList) throws Exception {
        minIOManager.deletes(urlList);
        return Result.success();
    }
}
